# TODO: Add comment
# 
# Author: Roger
###############################################################################



isMonday <- function(Date){
	# Date <- as.Date("2009-11-08")
	getWeekday(Date)==1
}
isTuesday <- function(Date){
	# Date <- as.Date("2009-11-08")
	getWeekday(Date)==2
}
isWednesday <- function(Date){
	# Date <- as.Date("2009-11-08")
	getWeekday(Date)==3
}
isThursday <- function(Date){
	# Date <- as.Date("2009-11-08")
	getWeekday(Date)==4
}
isFriday <- function(Date){
	# Date <- as.Date("2009-11-08")
	getWeekday(Date)==5
}
isSaturday <- function(Date){
	# Date <- as.Date("2009-11-07")
	getWeekday(Date)==6
}
isSunday <- function(Date){
	# Date <- as.Date("2009-11-08")
	getWeekday(Date)==0
}
isWeekend <- function(Date){
	# Date <- as.Date("2009-11-07")
	# Date <- as.Date("2009-11-08")
	isSaturday(Date) | isSunday(Date)
}
isWeekday <- function(Date){
	# Date <- as.Date("2009-11-05")
	# Date <- Sys.Date()
	!isWeekend(Date)
}

isFirstMonday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isMonday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}
isFirstTuesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isTuesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}
isFirstWednesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isWednesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}
isFirstThursday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isThursday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}
isFirstFriday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isFriday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}
isFirstSaturday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSaturday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}
isFirstSunday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSunday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==1
	Result
}

isSecondMonday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isMonday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}
isSecondTuesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isTuesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}
isSecondWednesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isWednesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}
isSecondThursday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isThursday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}
isSecondFriday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isFriday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}
isSecondSaturday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSaturday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}
isSecondSunday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSunday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==2
	Result
}

isThirdMonday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isMonday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}
isThirdTuesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isTuesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}
isThirdWednesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isWednesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}
isThirdThursday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isThursday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}
isThirdFriday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isFriday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}
isThirdSaturday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSaturday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}
isThirdSunday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSunday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==3
	Result
}

isFourthMonday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isMonday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}
isFourthTuesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isTuesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}
isFourthWednesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isWednesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}
isFourthThursday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isThursday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}
isFourthFriday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isFriday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}
isFourthSaturday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSaturday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}
isFourthSunday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSunday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==4
	Result
}

isFifthMonday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isMonday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}
isFifthTuesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isTuesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}
isFifthWednesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isWednesday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}
isFifthThursday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isThursday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}
isFifthFriday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isFriday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}
isFifthSaturday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSaturday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}
isFifthSunday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSunday(Date)
	Result[Result] <- getNthWeekday(Date[Result])==5
	Result
}

isLastMonday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isMonday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}
isLastTuesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isTuesday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}
isLastWednesday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isWednesday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}
isLastThursday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isThursday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}
isLastFriday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isFriday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}
isLastSaturday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSaturday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}
isLastSunday <- function(Date){
	# Date <- Sys.Date()+0:366
	Result <- isSunday(Date)
	Result[Result] <- isLastWeekday(Date[Result])
	Result	
}



